//
//  CollectionViewCell5.m
//  BLDMusics
//
//  Created by lxd on 16/3/28.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "CollectionViewCell5.h"


@interface CollectionViewCell5 ()

@property (nonatomic, strong) UILabel *reasonLabel;

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UIImageView *imag1;

@end




@implementation CollectionViewCell5

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createContrls];
    }
    return self;
}


- (void)createContrls {
    self.reasonLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_reasonLabel];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_nameLabel];
    
    self.imag1 = [[UIImageView alloc] init];
    [self.contentView addSubview:_imag1];

}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    self.backgroundColor = [UIColor colorWithRed:205 / 255.0 green:205 / 255.0 blue:205 / 255.0 alpha:0.2];
    
    _reasonLabel.frame = CGRectMake(0, 5, self.bounds.size.width, 20);
    _reasonLabel.textAlignment = NSTextAlignmentCenter;
    _reasonLabel.font = [UIFont systemFontOfSize:14];

    
    _nameLabel.frame = CGRectMake(0, 35, self.bounds.size.width, 25);
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    
    
    CGFloat width = self.bounds.size.width / 3;
    
    _imag1.frame = CGRectMake(0, self.bounds.size.height - 2 * width, width * 3, 2 * width);
    

}


- (void)setModel:(LXDLayoutModel *)model {
    _model = model;
    
    _nameLabel.text = _model.name;
    
    _reasonLabel.text = _model.reason;
    
    if (_model.picUrl) {
        [_imag1 sd_setImageWithURL:[NSURL URLWithString:self.model.picUrl]];
    } else {
        _imag1.image = [UIImage imageNamed:@"2.jpg"];
    }
}


@end
